﻿namespace EFMLEditor.Pages.PropertyPages
{
    using System;
    using System.Windows.Forms;

    using EFMLEditor.Internal;

    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            this.InitializeComponent();

            foreach (var d in EFMLEditor.Application.Documents)
            {
                comboBox1.Items.Add(d.Name);
            }
            foreach (var d in EFMLEditor.Application.Strings)
            {
                comboBox2.Items.Add(d.Name);
            }

            this.textBox1.Text = Global.Get("application_name");
            this.comboBox1.SelectedItem = Global.Get("application_mainwindow");
            this.comboBox2.SelectedItem = Global.Get("application_mainlanguage");
            this.textBox2.Text = Global.Get("application_icon");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.textBox2.Text = this.openFileDialog1.FileName;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            EFMLEditor.Application.isDirty = true;
            Global.Add("application_name", this.textBox1.Text);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            EFMLEditor.Application.isDirty = true;
            Global.Add("application_icon", this.textBox2.Text);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            EFMLEditor.Application.isDirty = true;
            Global.Add("application_mainwindow", this.comboBox1.SelectedItem.ToString());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var mi = new MoreInfos();
            mi.ShowDialog();
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            EFMLEditor.Application.isDirty = true;
            Global.Add("application_mainlanguage", this.comboBox2.SelectedItem.ToString());
        }
    }
}